#!/bin/bash

echo "** Initializing for tests"
curl "http://localhost:8080/WeddingApp/table/add?size=8";
curl "http://localhost:8080/WeddingApp/table/add?size=8";
curl "localhost:8080/WeddingApp/guest/add?name=Don%20Quixote&age=31&tid=1";
curl "http://localhost:8080/WeddingApp/guest/add?name=Sancho%20Panza&age=28&tid=1";
curl "http://localhost:8080/WeddingApp/guest/dislike?gid1=2&gid2=1";
curl "http://localhost:8080/WeddingApp/guest/add?name=asd&age=4&tid=4" > add_act.html 2> /dev/null;
curl "http://localhost:8080/WeddingApp/report" > report_act.html 2> /dev/null;
sleep 1;
echo -e "\n** Running tests\n";
add_tr=`diff -w -B add_act.html add_exp.html`;
report_tr=`diff -w -B report_act.html report_exp.html`;
if ["$add_tr" eq ""] && ["$report_tr" eq ""]; then 
	echo "Passed!";
	rm -f add_act.html;
	rm -f report_act.html;
else
	echo $add_tr;
	echo $report_tr;
	echo "Failed!"
fi
